package Demo8;

import java.util.Scanner;

public class WholeSale {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        String[] commodity={"电风扇","洗衣机","电视机","冰 箱","空调机"};
        double[] price={124.23,4500.0,8800.9,5000.88,4456.0};
        String[] change=new String[price.length];
        String total;
        double sum;
        System.out.println("**********欢迎进入商品批发城************");
        System.out.println("编号"+"\t\t商品"+"\t\t价格");
        System.out.println("1"+"\t\t"+commodity[0]+"\t "+price[0]);
        for(int i=1;i<5;i++){
            change[i]=String.valueOf(price[i]);
            StringBuffer str=new StringBuffer(change[i]);
            int index=str.indexOf(".");
                str.insert(index-3,',');
                System.out.println((i+1)+"\t\t"+commodity[i]+"\t "+str);
        }
        System.out.println("*******************************************");
        System.out.println("请输入您批发的商品编号：");
        int card=input.nextInt();
        System.out.println("请输入批发数量：");
        int num=input.nextInt();
        if(card==1){
            sum=price[0]*num;
            System.out.println("您需要付款："+sum);
        }else{
            sum=price[card-1]*num;
            total=String.valueOf(sum);
            StringBuffer str=new StringBuffer(total);
            int index2=total.indexOf(".");
            str.insert(index2-3,',');
            System.out.println("您需要付款："+str);
        }
    }
}
